


<style>
    .request_data_table input{width: 80px!important;padding-left: 10px;}
    .reward-tab{padding: 10px;height: 100%;width: 849px;margin-left: 69px;}
    .share-reward input{margin-top:20px;}
    .add-share,.add-team{cursor: pointer;background-color: rgb(0,166,90); display:inline-block;text-align: center;font-size: 20px; line-height: 22px;width: 22px}
    .reduce-share,.reduce-team{cursor: pointer;background-color:  rgb(221,75,57); display:inline-block;text-align: center;font-size: 20px; line-height: 22px;width: 22px}
</style>
<div class="x-body">
    <form class="layui-form form_single" action="{:url()}" method="post">
        <div class="layui-form-item">
            <label for="level_name" class="layui-form-label">
                <span class="x-red">*</span>等级名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="level_name" name="level_name" required="" lay-verify="required"
                       autocomplete="off"  value="{$info['level_name']|default=''}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
               （等级名称）
            </div>
        </div>
        <div class="layui-form-item">
            <label for="logo" class="layui-form-label">
                <span class="x-red">*</span>等级图标（165*128）
            </label>
            <div id="logo" class="layui-input-inline">
                {assign name="cover_id" value="$info.cover_id|default='0'" /}
                {:widget('file/index', ['name' => 'cover_id', 'value' => $cover_id, 'type' => 'img'])}
            </div>
            <!--<div class="layui-form-mid layui-word-aux">-->
            <!--(请上传单张封面图片)-->
            <!--</div>-->
        </div>
        <div class="layui-form-item">
            <label for="nickname" class="layui-form-label">
                <span class="x-red">*</span>等级别称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="nickname" name="nickname"
                       autocomplete="off" class="layui-input"  value="{$info['nickname']|default=''}">
            </div>
            <div class="layui-form-mid layui-word-aux">
              (等级别称)
            </div>
        </div>

        <div class="layui-form-item">
            <label for="share_number" class="layui-form-label">
                <span class="x-red">*</span>直推人数
            </label>
            <div class="layui-input-inline">
                <input type="number" id="share_number" name="share_number"
                       autocomplete="off" class="layui-input"  value="{$info['share_number']|default=''}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                （直推人数）
            </div>
        </div>




        <div class="share-reward" style="width: 1000px;padding: 20px 0;">
            {if condition="$info eq true"}
                {volist name="info.share_list" id="v" key="k"}

                    <span for="nickname" class="layui-form-label">
                          {if condition="$k eq 1 "}   <span class="x-red">*</span>团队奖{/if}
                        </span>
                    <div  class="request_data_table" >
                        <div class="reward-tab">
                            <span>拿<input type="number" class="share1"   name="share_first[]" value="{$v.level}" />代 </span>&nbsp;&nbsp;&nbsp;
                            {if condition="$v.reward eq true"}
                            {volist name='v.reward' id='ve' key='ke'}
                                {if condition="$ke eq 1 "}
                                     <br class="share-reward"/><span class="share-reward"> 第{$ke}代<input type="number"    name="share{$ke}[]" value="{$ve}" /> %</span>&nbsp;&nbsp;
                                {else/}
                                     <span class="share-reward"> 第{$ke}代<input type="number"    name="share{$ke}[]" value="{$ve}" /> %</span>&nbsp;&nbsp;
                                {/if}
                            {/volist}
                            {/if}
                            <b class="add-share" >+</b></a>&nbsp;&nbsp;  {if condition="$k neq 1 "}   <b class="reduce-share" >-</b>{/if}
                        </div>

                    </div>

                {/volist}

            {else/}
                <span for="nickname" class="layui-form-label">
                    <span class="x-red">*</span>团队奖
                </span>
                <div  class="request_data_table" >
                    <div class="reward-tab">
                       <span> 拿<input type="number" class="share1"  name="share_first[]" value="0" />代</span>&nbsp;&nbsp;&nbsp;<b class="add-share" >+</b></a>&nbsp;&nbsp;
                    </div>

                </div>
            {/if}



        </div>

        <div class="layui-form-item">
            <label for="share_reward_max" class="layui-form-label">
                <span class="x-red">*</span>团队奖日封顶（元）
            </label>
            <div class="layui-input-inline">
                <input type="number" id="share_reward_max" name="share_reward_max"
                       autocomplete="off" class="layui-input"  value="{$info['share_reward_max']|default=0}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                （团队奖日封顶（元））
            </div>
        </div>

        <div class="layui-form-item">
            <label for="share_reward_max" class="layui-form-label">
                <span class="x-red">*</span>平级奖（%）
            </label>
            <div class="layui-input-inline">
                <input type="number" id="reward" name="reward"
                       autocomplete="off" class="layui-input"  value="{$info['reward']|default=0}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                （平级奖（%））
            </div>
        </div>

        <div class="box-footer">

            <input type="hidden" name="id" value="{$info['id']|default='0'}"/>

            {include file="layout/edit_btn_group"/}

        </div>

    </form>
</div>

<script>
    $(function() {

        $('.share-reward').on('click','.add-share',(function () {
            var html = '  <span for="nickname" class="layui-form-label">\n' +
                '\n' +
                '            </span>\n' +
                '            <div  class="request_data_table" >\n' +
                '                <div class="reward-tab">\n' +
                '                     拿<span><input type="number" class="share1"   name="share_first[]" value="0" />代</span> &nbsp;&nbsp;&nbsp;<b class="add-share" >+</b>&nbsp;&nbsp; <b class="reduce-share" >-</b>\n' +
                '                </div>\n' +
                '\n' +
                '            </div>';

            $(this).parent().parent().after(html);


        }))


        $('.share-reward').on('click','.reduce-share',(function () {

            $(this).parent().parent().prev().remove();
            $(this).parent().parent().remove();


        }))


        $('.share-reward').on('blur','.share1',(function () {

            var  number=$(this).val();
            $(this).parent().parent().find('.share-reward').remove();
            if(number<=0){
                return ;
            }
            var html='';
            for (var i=1; i<=number;i++){
                if(i==1){
                    html+='<br class="share-reward"/><span class="share-reward"> 第'+i+'代<input type="number"    name="share'+i+'[]" value="0" /> %</span>&nbsp;&nbsp;';
                }else{
                    html+='<span class="share-reward"> ，第'+i+'代<input type="number"    name="share'+i+'[]" value="0" /> %</span>&nbsp;&nbsp;';
                }

            }
            console.log(html);
            $(this).parent().after(html);
        }))

        $('.share-reward').on('click','.add-team',(function () {
            var html = '  <span for="nickname" class="layui-form-label">\n' +
                '\n' +
                '            </span>\n' +
                '            <div  class="request_data_table" >\n' +
                '                <div class="reward-tab">\n' +
                '                    <span>团队升级金额<span><input type="number"  name="team[]" value="0" /></span><span>，拿<input type="number"  name="team1[]" value="0" />%</span> &nbsp;&nbsp;&nbsp;<b class="add-team" >+</b>&nbsp;&nbsp; <b class="reduce-team" >-</b>\n' +
                '                </div>\n' +
                '\n' +
                '            </div>';

            $(this).parent().parent().after(html);


        }))




        $('.share-reward').on('click','.reduce-team',(function () {

            $(this).parent().parent().prev().remove();
            $(this).parent().parent().remove();


        }))

    })
</script>

